﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MVCSiteJDG.Dao.DataAccess
{
    public class Writer
    {
        public static void writeAccount(string accountName, string accountPassword, string accountRegDate, string accountLastLogin, string accountEmail, string accountContactNumber, string accountBalance, string costCentreID, string accountID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update account set accountName=" + accountName + " ,accountPassword =" + accountPassword + " ,accountRegDate=" + accountRegDate + " ,accountLastLogin=" + accountLastLogin + " ,accountEmail=" + accountEmail + " ,accountContractNumber=" + accountContactNumber + " ,accountBalance=" + accountBalance + " ,accountCostCentre=" + costCentreID + " where accountID =" + accountID, connection);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        //public static void writeApplication(string Id)
        //{
        //    try
        //    {
        //        System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
        //        System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set  " + +"," + +"where id =" + Id);

        //        connection.Open();
        //        command.ExecuteNonQuery();
        //    }
        //    catch (Exception)
        //    {

        //    }
        //}
        public static void writeAsset(string departmentID, string subCategoryID, string productID, string assetID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set assetID =" + assetID + ", departmentID =" + departmentID + ", subCategoryID =" + subCategoryID + ", productID =" + productID + " where AssetID =" + assetID, connection);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeCartItem(string productID, string cartID, string cartItemID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set  productID" + productID + ",cartID" + cartID + " where cartItemID =" + cartItemID, connection);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeCatalog(string catName, string catDescription, string catImage, string catID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update catalog set catName = " + catName + ", catDescription = " + catDescription + ", catImage =" + catImage + " where catID =" + catID, connection);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        //public static void writeCatalogProduct(string prodId, string catId)
        //{
        //    try
        //    {
        //         System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
        //        System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set  " + +"," + +"where id =" + Id);

        //        connection.Open();
        //        command.ExecuteNonQuery();
        //    }
        //    catch (Exception)
        //    {

        //    }
        //}
        public static void writeCostCentre(string totalValue, string costCentreID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set totalValue " + totalValue + " where costCentreID =" + costCentreID, connection);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeDepartment(string departmentID, string building, string floor, string room, string costCentreId)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set building = " + building + " ,floor =" + floor + " ,room =" + room + ",costCentreId =" + costCentreId + "where departmentID=" + departmentID, connection);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        //public static void writeEmployee(string Id)
        //{
        //    try
        //    {
        //        System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
        //        System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set  " + +"," + +"where id =" + Id);

        //        connection.Open();
        //        command.ExecuteNonQuery();
        //    }
        //    catch (Exception)
        //    {

        //    }
        //}
        public static void writeLog(string logID, string requestID, string message)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set requestID=" + requestID + ",message=" + message + "where logID =" + logID, connection);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeMainCategory(string mainCategoryID, string description)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set description= " + description + " where mainCategoryID =" + mainCategoryID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeOrders(string orderID, string orderStatus, string orderTotalCost, string departmentID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set orderStatus= " + orderStatus + ",orderTotalCost=" + orderTotalCost + ",departmentID=" + departmentID + " where orderID =" + orderID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeOrderLineItem(string orderLineID, string productID, string productQuantity, string orderID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set productID= " + productID + ",productQuantity=" + productQuantity + ",orderID=" + orderID + " where orderLineID =" + orderLineID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        //public static void writeOrderStatus(string OrderStatusId, string description)
        //{
        //    try
        //    {
        //        System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
        //        System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set  " + +"," + +"where id =" + Id);

        //        connection.Open();
        //        command.ExecuteNonQuery();
        //    }
        //    catch (Exception)
        //    {

        //    }
        //}
        public static void writeProduct(string productID, string productName, string productDescription, string productPrice, string productImage, string productInDate, string catID)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set productName= " + productName + ",productDescription=" + productDescription + ",productPrice=" + productPrice + ",productImage=" + productImage + ",productInDate" + productInDate + ",catID" + catID + "where productID =" + productID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeReview(string reviewID, string accountID, string technicianID, string requestMessage)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set accountID= " + accountID + ",technicianID=" + technicianID + ",requestMessage=" + requestMessage + "where reviewID =" + reviewID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeSubCategory(string subCategoryID, string mainCategoryID, string description)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set mainCategoryID= " + mainCategoryID + ",mainCategoryID=" + mainCategoryID + "where subCategoryID =" + subCategoryID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeSupplier(string supplierID, string supplierName)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set supplierName= " + supplierName + " where supplierID =" + supplierID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
        public static void writeTechnician(string technicianID, string technicianName)
        {
            try
            {
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source= |DataDirectory|\\MyDatabase#1.sdf");
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand("update application set technicianName= " + technicianName + "where technicianID =" + technicianID);

                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
        }
    }
}